import { $post, $get, $delete, $put } from "@/utils/request";

// 获取医生列表
export const $DoctorList = async () => {
    return await $post("/doctor/Inquire");
}

// 获取医生详情
export const $DoctorDetail = async (params: object) => {
    const { id } = params ?? 0;
    return await $post(`/doctor/InquireId?id=${id}`);
}

// 获取对应科室的医生列表
export const $DoctorListByDepartment = async (params: object) => {
    const { department } = params;
    return await $post(`/doctor/Department?department=${department}`);
}

// 获取医生排班
export const $DoctorSchedule = async (params: object) => {
    const { id } = params;
    return await $post(`/doctor/InquireIdtime?id=${id}`);
}

// 删除医生信息
export const $DeleteDoctor = async (params: object) => {
    const queryParams = params.map(id => `ids=${id}`).join('&');
    return await $delete(`/doctor/deleteDoctor?${queryParams}`)
}

// 添加医生信息
export const $InsertDoctor = async (params: object) => {
    const { name, position, department, url, time, good, introduction } = params;
    return await $post(`/doctor/insertDoctor?name=${name}&position=${position}&department=${department}&url=${url}&time=${time}&good=${good}&introduction=${introduction}`)
}

// 更新医生信息
export const $UpdateDoctor = async (params: object) => {
    const { id, name, position, department, url, time, good, introduction } = params;
    return await $put(`/doctor/updateDoctor?id=${id}&name=${name}&position=${position}&department=${department}&url=${url}&time=${time}&good=${good}&introduction=${introduction}`)
}